﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PgBirdie.Core.Model;
using PgBirdie.Core.Model.Database.AccessControl;
using PgBirdie.Core.Model.Database.Structure;
using PgBirdie.Core.Model.Database.Structure.Constraint;
using PgBirdie.Core.Model.Database.Structure.Index;

namespace PgBirdie.Core.Service.Dump
{
    /// <summary>
    /// Retrieves db objects from pg_dump.exe's sql/text.
    /// </summary>
    public interface IDbObjectFromPgDumpService
    {
        /// <summary>
        /// Gets current search path (a.k.a. schema name).
        /// </summary>
        string GetCurrentSearchPath(string text);

        PgSchema GetCurrentSchema(string currentSearchPath, PgDatabase db);

        PgDatabase GetDatabase(string text);

        PgSchema GetSchema(string text);

        PgTable GetTable(string text);

        string GetSequenceName(string text);
        long GetSequenceStartWith(string text);
        long GetSequenceIncrementBy(string text);
        long GetSequenceMinValue(string text);
        long GetSequenceMaxValue(string text);
        long GetSequenceCache(string text);

        ColumnDataType GetColumnDataType(string text);

        /// <summary>
        /// Get column definition from a sql line broken into segments.
        /// </summary>
        PgColumn GetColumn(string text);

        string GetColumnSequenceName(string text);

        /// <summary>
        /// Get index definition from a sql line broken into segments.
        /// </summary>
        PgIndex GetIndex(string line, string[] segments, bool isClustered);

        /// <summary>
        /// Get constraint definition from a sql line broken into segments.
        /// </summary>
        PgConstraintBase GetConstraint(List<string> segments, PgTable table);

        PgOwner GetOwner(string text, PgDbObject targetDbObject);

        PgDbObjectType GetDbObjectTypeFromPrivilege(string text);
        string GetDbObjectNameFromPrivilege(string text);
        PgPrivilege GetPrivilege(string text, object targetDbObject);
    }
}
